package com.xxgc.vfc.common.error.center.system;


import com.xxgc.vfc.api.result.Result;
import com.xxgc.vfc.common.error.center.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*
 *   @Author: Sjy
 *   @Date: 2023/11/8-11-08-9:25
 *   系统常见异常
 */
@Slf4j
@ResponseBody
@ControllerAdvice
public class SystemException{

    //对象为空
    @ExceptionHandler(value = {IllegalArgumentException.class})
    public ResponseEntity<Result> illegalArgumentException(Exception e){
        //去获取接口信息和传入参数，一起返回给运维

        return new ResponseEntity<Result>(
                Result.error().data(new BaseException("VFC-1108-SYSTEM-0001", e.getMessage())),
                HttpStatus.INTERNAL_SERVER_ERROR
        );
    }

}
